package com.shiroha.user.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import com.mybatisflex.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum ApplyStatus {
    PENDING(0, "待处理"),
    APPROVED(1, "已通过"),
    REJECTED(2, "已拒绝"),
    ;

    @EnumValue
    @JsonValue
    private final int value;
    private final String description;

    ApplyStatus(int value, String description) {
        this.value = value;
        this.description = description;
    }

    /**
     * 根据 value 获取枚举实例
     */
    public static ApplyStatus fromValue(int value) {
        for (ApplyStatus status : ApplyStatus.values()) {
            if (status.getValue() == value) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的状态值: " + value);
    }
}
